package com.wink.admin.utils;

import cn.hutool.json.JSONObject;
import com.wink.admin.entity.SysUser;
import lombok.extern.slf4j.Slf4j;

/**
 * 获取登录信息
 *
 * @author xw
 */
@Slf4j
public class LoginUtils {

    public static JSONObject getThreadData() {
        return (JSONObject) ThreadLocalUtils.getObject();
    }

    public static Long getUserLoginId() {
        JSONObject data = getThreadData();
        return data.getLong("id");
    }



    /**
     * 获取登录名称
     */
    public static String getUserName() {
        JSONObject data = getThreadData();
        return data.getStr("username","null");
    }

    /**
     * 获取登录用户
     *
     * @return
     */
    public static SysUser getUser() {
        return getThreadData().toBean(SysUser.class);
    }

}
